package com.ljd.controller;


import com.ljd.entity.EduVideo;
import com.ljd.service.EduVideoService;
import com.ljd.util.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author ljd
 * @since 2021-12-10
 */
@RestController
@RequestMapping("/eduservice/video")
//@CrossOrigin
public class EduVideoController {
    @Autowired
    private EduVideoService videoService;
    @ApiOperation("添加小节")
    @PostMapping("saveVideo")
    public R saveVideo(@RequestBody EduVideo video){
        videoService.saveVideo(video);
        return R.ok();
    }
    @ApiOperation("修改小节")
    @PostMapping("/updateVideo")
    public R updateVideo(@RequestBody EduVideo video){
        videoService.updateVideo(video);
        return R.ok();
    }
    @ApiOperation("删除小节")
    @DeleteMapping("deleteVideo/{videoId}")
    public R deleteVideo(@PathVariable String videoId){
        Boolean flag = videoService.deleteVideo(videoId);
        if(flag){
            return R.ok();
        }
        return R.error();
    }
    @ApiOperation("查询小节")
    @GetMapping("/getVideo/{videoId}")
    public R getVideo(@PathVariable String videoId){
        EduVideo video = videoService.getVideo(videoId);
        return R.ok().data("video",video);
    }

}

